﻿<?
require_once "inc.init.php";

// THE OBJ:
$obj = new donaciones(); // <---- Change this !!!
$obj-> setDbLink($dbLink);

// DEFINING MISC VARS
$table   = $obj->_dbTable;
$indexID = $obj->_dbIndex;

// MESSENGER
$messenger = new Messenger();
if ($_GET['msgError'])
{
    $messenger->setMessageType(-1);
    $messenger->addMessage( strip_tags(urldecode($_GET['msgError']) ) );
}

// SEARCH vars ans HTML
$searchFields = array($indexID, "email", "nombre_apellido", "telefono"); // inc.search.php explains this
$order = "donacionID desc";
include DIR_ADMIN."/common/inc.search.php"; // inc.search.php sets several variables. See "variables setted"
$columnUrl = "index.php?". $columnUrl;

// MAIN QUERY
$sql = "SELECT * FROM ". $table ." WHERE ". $condition . $order ." LIMIT ". $position .", ". $module->numMaxListedRows;
$res = mysql_query($sql, $dbLink);

?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>AdMin | <?= $GLOBALS["website"]["name"] ?></title>
    <meta name="description" content="mobile first, app, web app, responsive, admin dashboard, flat, flat ui">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> 
    <link rel="stylesheet" href="<?= $GLOBALS['CONF']['url']['admin']?>/css/bootstrap.css">
    <link rel="stylesheet" href="<?= $GLOBALS['CONF']['url']['admin']?>/css/font-awesome.min.css">
    <link rel="stylesheet" href="<?= $GLOBALS['CONF']['url']['admin']?>/css/plugin.css">
    <link rel="stylesheet" href="<?= $GLOBALS['CONF']['url']['admin']?>/css/font.css" cache="false">
    <link rel="stylesheet" href="<?= $GLOBALS['CONF']['url']['admin']?>/css/style.css">
    <!--[if lt IE 9]>
    <script src="js/ie/respond.min.js" cache="false"></script>
    <script src="js/ie/html5.js" cache="false"></script>
    <![endif]-->
    <script src="<?= $GLOBALS['CONF']['url']['js'] ?>/lib/prototype-min.js" type="text/javascript" language="javascript" charset="utf-8"></script>
    <?=jquery()?>
    <?=jqueryui()?>
    <script type="text/javascript">
        var $j = jQuery.noConflict();
    </script>
    <script language="JavaScript" type="text/javascript" src="<?= $GLOBALS["CONF"]["url"]["js"] ?>/lib/tiny_mce/tinymce.min.js"></script>
<script src="<?= $GLOBALS["CONF"]["url"]["js"] ?>/lib/scriptaculous/scriptaculous.js?load=effects,controls,dragdrop" type="text/javascript" language="javascript" charset="utf-8"></script>
<script type='text/javascript' src='<?= $GLOBALS["CONF"]["url"]["js"] ?>/lib/litbox.js'></script>
<script type="text/javascript">
    function deletionConfirmDialog(id)
    {
        if (confirm('Are you sure you want to delete the content?')) {
                location.replace("?action=delete&<?= $indexID ?>="+id);
        } else {
            // Do nothing!
        }
    };
</script>
    <style>
    .left{
        float:left;
    }
    .right{
        float:right;
    }
    .end{
        clear:both;
    }
    </style>
</head>
<body>
    <section id="container">
        <?
        if($messenger)
        {
            $messages = $messenger->getArMessages();
            if(count($messages))
            {
                $html='<div id="respuesta_estado_orden" class="hidden alert fade in"><div class="left">';
                foreach($message as $key => $value)
                {
                    $html.=$value."<br>";
                }
                $html.='</div>
                            <div class="right">
                                <button class="btn_close_messeger close" data-dismiss="alert" type="button">×</button>
                            </div>
                            <div class="end"></div>
                        </div>';
            }
        }
        ?>
        <div class="row"><br>
            <div class="col-lg-12">
<section class="panel">
            <header class="panel-heading"><b><a href="index.php"><?= $module->name ?></a></b></header>
            <div class="panel-body">
              <div class="row text-small">
                <div class="col-sm-4 m-b-mini pull-left">
                    <a class="btn btn-sm btn-info" href="export.php?export=1"><i class="icon-download-alt"></i> Exportar</a>
                </div>
                <div class="col-sm-4 pull-right">
                    <form method="get" action="index.php" name="form1">
                        <div id="SearchFormBox">
                            <div class="input-group">
                                <input type="text" class="input-sm form-control" placeholder="Search" name="search" value="<?=$_GET['search']?>">
                                <span class="input-group-btn">
                                    <button class="btn btn-sm btn-white" type="submit">Go!</button>
                                </span>&nbsp;
                                <a href="index.php">[Reset]</a>
                            </div>
                        </div>
                    </form>
                </div>
              </div>
            </div>
            <div class="table-responsive">
              <table class="table table-striped b-t text-small">
                <thead>
                  <tr>
                    <th class="th-sortable" data-toggle="class">
                        <a href="<?= $columnUrl . $indexID ?>"><?= $indexID ?>
                            <span class="th-sort">
                                <?
                                if($_GET['order']=='donacionID')
                                {
                                    ?>
                                    <i class="icon-sort-down text<?=($_GET['order_type'] == 'ASC'?'-active':'')?>"></i>
                                    <i class="icon-sort-up text<?=($_GET['order_type'] == 'DESC'?'-active':'')?>"></i>
                                    <?
                                }
                                ?>
                                <i class="icon-sort"></i>
                            </span>
                        </a>
                    </th>
                    <th>
                        <a href="<?= $columnUrl . "nombre_apellido" ?>">Nombre y Apellido
                            <span class="th-sort">
                                <?
                                if($_GET['order']=='nombre_apellido')
                                {
                                    ?>
                                    <i class="icon-sort-down text<?=($_GET['order_type'] == 'ASC'?'-active':'')?>"></i>
                                    <i class="icon-sort-up text<?=($_GET['order_type'] == 'DESC'?'-active':'')?>"></i>
                                    <?
                                }
                                ?>
                                <i class="icon-sort"></i>
                            </span>
                        </a>
                    </th>
                    <th class="th-sortable" data-toggle="class">
                        <a href="<?= $columnUrl . 'email' ?>">Email
                            <span class="th-sort">
                                <?
                                if($_GET['order']=='email')
                                {
                                    ?>
                                        <i class="icon-sort-down text<?=($_GET['order_type'] == 'ASC'?'-active':'')?>"></i>
                                        <i class="icon-sort-up text<?=($_GET['order_type'] == 'DESC'?'-active':'')?>"></i>
                                    <?
                                }
                                ?>
                                <i class="icon-sort"></i>
                            </span>
                        </a>
                    </th>
                    <th>
                        <a href="<?= $columnUrl . "telefono" ?>">Tel&eacute;fono
                            <span class="th-sort">
                                <?
                                if($_GET['order']=='telefono')
                                {
                                    ?>
                                    <i class="icon-sort-down text<?=($_GET['order_type'] == 'ASC'?'-active':'')?>"></i>
                                    <i class="icon-sort-up text<?=($_GET['order_type'] == 'DESC'?'-active':'')?>"></i>
                                    <?
                                }
                                ?>
                                <i class="icon-sort"></i>
                            </span>
                        </a>
                    </th>
                    <th>Mensaje</th>
                    <th class="th-sortable" data-toggle="class">
                        <a href="<?= $columnUrl . 'date_created' ?>">Date Created
                            <span class="th-sort">
                                <?
                                if($_GET['order']=='date_created')
                                {
                                    ?>
                                        <i class="icon-sort-down text<?=($_GET['order_type'] == 'ASC'?'-active':'')?>"></i>
                                        <i class="icon-sort-up text<?=($_GET['order_type'] == 'DESC'?'-active':'')?>"></i>
                                    <?
                                }
                                ?>
                                <i class="icon-sort"></i>
                            </span>
                        </a>
                    </th>
                  </tr>
                </thead>
                <tbody>
                    <?
                    while($row = mysql_fetch_array($res))
                    {
                        $onClick = "document.location='details.php?". $indexID ."=". $row[$indexID] ."';return false";
                        ?>
                        <tr>
                            <td><?=$row[$indexID]?></td>
                            <td><?=$row['nombre_apellido']?></td>
                            <td><?=$row['email']?></td>
                            <td><?=$row['telefono']?></td>
                            <td><?=$row['mensaje']?></td>
                            <td><?= $row['date_created']?></td>
                        </tr>
                        <?
                    }
                    ?>
                </tbody>
              </table>
            </div>
            <footer class="panel-footer">
              <div class="row">
                <div class="col-sm-5 text-right text-center-sm pull-right"><? showListPagination($urlVars, $numTotalRows); ?></div>
              </div>
            </footer>
    </section>
    <script src="<?=$GLOBALS['CONF']['url']['admin']?>/js/jquery.min.js"></script>
    <!-- Bootstrap -->
    <script src="<?=$GLOBALS['CONF']['url']['admin']?>/js/bootstrap.js"></script>
    <!-- fuelux -->
    <script src="<?=$GLOBALS['CONF']['url']['admin']?>/js/fuelux/fuelux.js"></script>
    <script src="<?=$GLOBALS['CONF']['url']['admin']?>/js/underscore-min.js"></script>
    <!-- datatables -->
    <script src="<?=$GLOBALS['CONF']['url']['admin']?>/js/datatables/jquery.dataTables.min.js"></script>
</body>
</html>
